package com.example.naverbooksearch;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class NaverBookItemAdapter extends BaseAdapter {

	ArrayList<NaverBookItem> items;
	Context mContext;
	
	public NaverBookItemAdapter(Context context, ArrayList<NaverBookItem> items) {
		mContext = context;
		if(items == null) {
			items = new ArrayList<NaverBookItem>();
		}
		this.items = items;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	@Override
	public NaverBookItem getItem(int position) {
		// TODO Auto-generated method stub
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ItemView v;
		if(convertView == null) {
			v = new ItemView(mContext);
		} else {
			v = (ItemView) convertView;
		}
		v.setItemData(items.get(position));
		return v;
	}

}
